Module modXML
    Public Sub writeConfiguration()
        Dim xml As Xml.XmlTextWriter

        xml = New Xml.XmlTextWriter(Application.StartupPath & "\clientConfig.xml", Nothing)

        With xml
            .Indentation = 4
            .IndentChar = " "
            .Formatting = .Indentation
            .WriteStartDocument()

            .WriteComment("ERN Client Version: " & commonGlobals.ernClientVersion)
            .WriteStartElement("General")
            .WriteElementString("Server", frmMain.net.getServerName)
            .WriteElementString("clientGUID", frmMain.clientGUID)
            .WriteEndElement() 'end GENERAL

            .WriteEndDocument()
            .Flush()
            .Close()
        End With
    End Sub

    Public Sub readConfiguration()
        Dim xml As New Xml.XmlDocument
        Dim nodeList As Xml.XmlNodeList
        Dim node As Xml.XmlNode

        Dim serverName As String = "localhost"
        Dim clientID As String = "0"

        If System.IO.File.Exists(Application.StartupPath & "\clientConfig.xml") Then
            xml.Load(Application.StartupPath & "\clientConfig.xml")
            nodeList = xml.SelectNodes("/General")
            For Each node In nodeList
                serverName = node.ChildNodes.Item(0).InnerText
                clientID = node.ChildNodes.Item(1).InnerText
            Next
        End If

        frmMain.net.setServerName(serverName)
        frmMain.clientGUID = clientID
    End Sub
End Module
